<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>tmp.html</title>

<script type="text/javascript">

	// Simple obj
	var empty_obj = {};
	
	var storage = {
			
			name		: "adriano",
			email		: "adrianojlt@gmail.com",
			"myString"	: "one string",
			printAll	: 	function() {
								// ... do something
								console.log("text from a function");
							},
	};
	
	
	
	var flight = {
		    airline		: "Oceanic",
		    number		: 815,
		    departure: {
		       			IATA: "SYD",
		        		time: "2004-09-22 14:55",
		        		city: "Sydney"
		    },
		    arrival: {
		        		IATA: "LAX",
		        		time: "2004-09-23 10:42",
		        		city: "Los Angeles"
		    }
		};
	
	
	// An object literal is a way to encapsulate related bahviours
	var myObjLiteral = {
		
		myBehaviour1	: function() {
			/* do something */
		},	
	
		myBehaviour2	: function() {
			
		}
	};
	


	function myArray() {
		
		var myArray = ['primeiro','segundoi','terceiro'];
		var charArr = ['h','e','l','l','o'];
		var myStr 	= charArr.join('');
		/* console.log(myStr);
		console.log(storage.name);
		console.log(storage.printAll()); */
	}
	
	// return a function 
	var greet = function(person, greeting) {
		var text = greeting + ', ' + person;
		return function() { console.log(text); };
	};
	
	// use the previous function
	function usePrevious() {
		var greeting = greet('rebecca','hello');
		greeting();
	}
	
	// function that receives anoter one as an argument
	var myFn = function (fn) {
		var res = fn();
		console.log(res);
	}
	
	// function to be used as an argument
	var myOtherFn = function() {
		return 'hello from  myOtherFn';
	}
	
	
	
	function resize(imgW, imgH, moldW, moldH) {
		var ratio; 
		var x;
		var y;
		
		if (imgH > imgW)
			ratio = imgW/imgH;
		else
			ratio = imgH/imgW;
				
		if (imgW >= moldW) {
			x = moldW;
			y = x*ratio;
		}
		
		if (imgH >= moldH) {
			y = moldH;
			x = y*ratio;
		}
	}
	


</script>

</head>
<body onload="myArray()">

<script>
	// this is the first sentence executed
	//usePrevious();
	
	//myFn(myOtherFn);
	
	
	console.log(window.screen.colorDepth);
	
	
</script>


<input type="button" value="calc2" onclick="calc2()" />



</body>
</html>